<?php if (!defined('THINK_PATH')) exit();?>								<div style="position:absolute;top: 16px;right: 20px;">待发货总金额：AU$<span style="color:red;"><?php echo ($all_money["available_for_all_money"]); ?>&nbsp;&nbsp;</span>
								可售总金额：AU$<span style="color:red;"><?php echo ($all_money["wait_for_all_money"]); ?>&nbsp;&nbsp;</span>
								虚拟仓总金额：AU$<span style="color:red;"><?php echo ($all_money["all_money"]); ?></span></div>
								<table id="sample-table-2" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th width="5%">序号</th>
											<th width="10%">51M货号</th>
											<th width="10%">商品条形码</th>
											<th width="15%">商品名称</th>
											<th width="10%">商品中文名</th>
											<th width="10%">单价($)(不含GST)</th>
											<th width="6%">GST($)</th>
											<!-- <th width="8%">待发货库存</th> -->
											
											<?php if($order == 'salenumber' and $sort == 'DESC'): ?><th width="8%" onclick="field_sort('salenumber','ASC')" style="cursor:pointer">待发货库存 <span style="float:right"><i class="icon-chevron-up"></i></span></th>
											<?php else: ?>
													<th width="8%" onclick="field_sort('salenumber','DESC')" style="cursor:pointer">待发货库存 <span style="float:right"><i class="icon-chevron-down"></i></span></th><?php endif; ?>


											<?php if($order == 'quantity' and $sort == 'DESC'): ?><th width="8%" onclick="field_sort('quantity','ASC')" style="cursor:pointer">虚拟仓库存 <span style="float:right"><i class="icon-chevron-up"></i></span></th>
											<?php else: ?>
													<th width="8%" onclick="field_sort('quantity','DESC')" style="cursor:pointer">虚拟仓库存 <span style="float:right"><i class="icon-chevron-down"></i></span></th><?php endif; ?>


                                           
											<?php if($order == 'actual' and $sort == 'DESC' or $jump_stock == 1): ?><th width="8%" onclick="field_sort('actual','ASC')" style="cursor:pointer">可售库存 <span style="float:right"><i class="icon-chevron-up"></i></span></th>
											<?php else: ?>
													<th width="8%" onclick="field_sort('actual','DESC')" style="cursor:pointer">可售库存 <span style="float:right"><i class="icon-chevron-down"></i></span></th><?php endif; ?>
											<!-- <th width="8%">实际库存</th> -->

                                            
											<!-- <?php if($order == 'create_time' and $sort == 'DESC' ): ?><th width="10%" onclick="field_sort('create_time','ASC')" style="cursor:pointer">采购时间<span style="float:right"><i class="icon-chevron-up"></i> </span></th>
											<?php else: ?>
													<th width="10%" onclick="field_sort('create_time','DESC')" style="cursor:pointer">采购时间<span style="float:right"><i class="icon-chevron-down"></i></span></th><?php endif; ?> -->


											<?php if($order == 'sum' and $sort == 'DESC' ): ?><th width="10%" onclick="field_sort('sum','ASC')" style="cursor:pointer">虚拟仓小计(AU$)<span style="float:right"><i class="icon-chevron-up"></i> </span></th>
											<?php else: ?>
													<th width="10%" onclick="field_sort('sum','DESC')" style="cursor:pointer">虚拟仓小计(AU$)<span style="float:right"><i class="icon-chevron-down"></i></span></th><?php endif; ?>
											<th width="6%">操作</th>
										</tr>
									</thead>
									<tbody>
										<?php if(is_array($lists['lists'])): $i = 0; $__LIST__ = $lists['lists'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>

												<td>
													<a href="#"><?php echo ($i); ?></a>
												</td>
												<td><?php echo ($vo["goods_sn"]); ?></td>
												<td><?php echo ($vo["bar_code"]); ?></td>
												<td><?php echo ($vo["goods_name"]); ?></td>
												<td><?php echo ($vo["goods_cn_name"]); ?></td>
												<td><?php echo ($vo["goods_price"]); ?></td>
												<td><?php echo ($vo["taxrate"]); ?></td>

												<td><?php echo ($vo["salenumber"]); ?></td>
									
												
		
												<td><?php echo ($vo["quantity"]); ?></td>
									

												<?php if(($vo['quantity']-$vo['salenumber']) <= C('MINIMUM_SYOCK_NUMBER')): ?><td style="color:red;"><?php echo ($vo['quantity'] - $vo['salenumber']); ?></td>
												<?php else: ?>
												<td><?php echo ($vo['quantity'] - $vo['salenumber']); ?></td><?php endif; ?>
												<!-- <td><?php echo (date("Y-m-d H:i:s",$vo["create_time"])); ?></td> -->
												<td><?php echo ($vo["sum_money"]); ?></td>
												<td><a href="#" field='"goods_id":"<?php echo ($vo["id"]); ?>","goods_sn":"<?php echo ($vo["goods_sn"]); ?>","goods_name":"<?php echo ($vo["goods_name"]); ?>","goods_price":"<?php echo ($vo["goods_price"]); ?>","salenumber":"<?php echo ($vo["salenumber"]); ?>","quantity":"<?php echo ($vo["quantity"]); ?>"' class="btn btn-sm btn-success" onclick="quantity_price(this)">添加购物车</a></td>
											</tr><?php endforeach; endif; else: echo "" ;endif; ?>
									</tbody>
								</table>
							<!-- <div style="float:right;margin-right:20px">页小计:AU$<span style="color:red;"><?php echo ($sum_money); ?></span></div> -->
							<div class="clearfix"></div>
							<div style="float:right;margin-right:20px">虚拟仓小计:AU$<span style="color:red;"><?php echo ($sum["fictitious_money"]); ?></span></div>
							<div style="float:right;margin-right:20px">可售小计:AU$<span style="color:red;"><?php echo ($sum["wait_for_deliver_money"]); ?></span></div>
							<div style="float:right;margin-right:20px">待发货小计:AU$<span style="color:red;"><?php echo ($sum["available_for_sale_money"]); ?></span></div>
							<div class="clearfix"></div>
					<table style="width: 80%; float: right; margin-bottom:10px">
					    <tr>
					        <td style="text-align: right;"> <div class="page_list_ops dataTables_paginate paging_bootstrap pagination" ><?php echo ($lists['page_html']); ?></div></td>
					    </tr>
					</table>


<div class='boxy' style="display:none; width:300px; height:120px;" id="boxy">  
                                            <div class="widget-body"><div class="widget-body-inner" style="display: block;">
                                                <div class="widget-main no-padding">
                                                    <table class="table table-bordered table-striped center">
                                                        <tbody id="tab_lists">
                                                            <tr>
                                                               <th width="30%">商　品　名</th>
                                                               <th id="goodsname"></th>
                                                            </tr>
                                                            <tr>
                                                               <th >商品编号</th>
                                                               <th id="goods_sn"></th>
                                                            </tr>
                                                            <tr>
                                                               <th >商品数量</th>
                                                               <th ><input style="width:80px"  type="number" min="1" name="number" id="number" value="1"></th>
                                                            </tr>
                                                            </div>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div></div>

                    </div>
<script type="text/javascript">
var cookiename="goods_order_<?php echo UID; ?>";
var where = '<?php echo ($where); ?>';


/*$(function(){
	  $("input[type=number]").on('input',function(e){
	  	alert(123);
           var old_number =  $(this).attr('number');
           var json_number =$(this).attr('json_number');
           var salenumber =  $(this).attr('salenumber');
           var quantity =  $(this).attr('quantity');
           var goods_number = $(this).val();
           var goods_price = $(this).parent('td').prev().html();
           if(goods_number >(quantity-salenumber)){
              $(this).val(quantity-salenumber);
              showvfmsg(0, '商品数量大于可售数量', 2000);return;
           }
           $(this).parent('td').next().html((goods_number*goods_price).toFixed(2));
           var sum_price_a = $('#sum_price_float').html();
           var sum_price_new = parseFloat(sum_price_a -(old_number*goods_price) + (goods_number*goods_price) );
           $('#sum_price_float').html(sum_price_new.toFixed(2));
           $(this).attr('number',goods_number);
        }); 
})*/
//点击表头排序
function field_sort(field,sort){
	var _url = "<?php echo U('MyWarehouse/MyWarehouseList');?>";
	var id = "order_list_item_content";
	var res = $.parseJSON(where);
	  res.order = field;
       res.sort = sort;
      _load_html_byurl(_url,id,res);
	}


//弹出商品填写商品数量添加购物车
function quantity_price(_this){
	var _tmv="{"+$(_this).attr("field")+"}";
	var _json=JSON.parse(_tmv); 
	if(!_json)return;
	// console.log(_json.goods_name);
	$('#goodsname').html(_json.goods_name);
	$('#goods_sn').html(_json.goods_sn);
    var dialog = art.dialog({
    title: '填写商品数量',
    lock:true,
    content: document.getElementById("boxy"),
    ok: function(){
       //获取到商品数量并添加到json中
       var number = $('#number').val();
       if(number<=0){
       	  showvfmsg('0','请填写有效数量',2000);return false;
       }
       if(number>(_json.quantity -_json.salenumber)){
          $("input[type=number]").val(_json.quantity -_json.salenumber);
       	  showvfmsg('0','该数量不能大于可售数量',2000);return false;
       }
       if(_json.goods_price<=0){
       	  showvfmsg('0','该商品的价格错误',2000);return false;
       }
      _json.number = number;
    var ojson = [];
    var _list=getCookie(cookiename);
    if(_list !=null && _list!="" ){
       ojson=JSON.parse(_list);
    } 
    var bl=isExist(ojson,_json.goods_id);
    if(!bl ){ojson.push(_json);}else{showvfmsg(0, '该商品已经在购物车中了', 2000);return;}
         var count = ojson.length;
     $('#pre_order_count').html('+'+count);
     var _jsona=JSON.stringify(ojson);
    //考虑重复记录的清理。 
    setCookie(cookiename,"",-10);
    setCookie(cookiename,_jsona,1);
	 showvfmsg(1, '添加成功', 2000);
    },
    cancelVal: '关闭',
    cancel:true,
    close:function(){
      load();
    }
});

}

 //判断json数据中是否存在商品编号id
 function isExist(ary,val){
      var flg=false;
      if(ary==null || ary.length==0)return flg;
      for(var i=0;i<ary.length;i++){
          if(ary[i]['goods_id']==val){
              flg=true;
              break;
          }
      }
      return flg;
 }
//写入cookie
 function setCookie(c_name, value, expiredays){
    if(expiredays < 0){
        localStorage.removeItem(c_name);
    }
       localStorage.setItem(c_name,value); //存储名字为name值为caibin的变量
 }
//读取cookie   
 function getCookie(c_name){
    return  localStorage.getItem(c_name);
 }
</script>